#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @time     : 2019-07-30 15:06
# @Author   : BYF
# file      : const.py
# @version  :


class _const:
    class ConstError(TypeError):
        pass

    class ConstCaseError(ConstError):
        pass

    def __setattr__(self, name, value):
        if name in self.__dict__:
            raise self.ConstError("Can not change const.{name}".format(name=name))
        if not name.isupper():
            raise self.ConstCaseError("const name {name} is not all uppercase".format(name=name))

        self.__dict__[name] = value


import sys

sys.modules[__name__] = _const()
